

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    
    <title>ccqw.coordDialog &mdash; CCQW 0.1.1 documentation</title>
    
    <link rel="stylesheet" href="../../_static/default.css" type="text/css" />
    <link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />
    
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    '../../',
        VERSION:     '0.1.1',
        COLLAPSE_INDEX: false,
        FILE_SUFFIX: '.html',
        HAS_SOURCE:  true
      };
    </script>
    <script type="text/javascript" src="../../_static/jquery.js"></script>
    <script type="text/javascript" src="../../_static/underscore.js"></script>
    <script type="text/javascript" src="../../_static/doctools.js"></script>
    <script type="text/javascript" src="../../_static/sidebar.js"></script>
    <link rel="top" title="CCQW 0.1.1 documentation" href="../../index.html" />
    <link rel="up" title="Module code" href="../index.html" /> 
  </head>
  <body>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../../genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="../../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li><a href="../../index.html">CCQW 0.1.1 documentation</a> &raquo;</li>
          <li><a href="../index.html" accesskey="U">Module code</a> &raquo;</li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body">
            
  <h1>Source code for ccqw.coordDialog</h1><div class="highlight"><pre>
<span class="c"># -*- coding: utf-8 -*-</span>
<span class="sd">&quot;&quot;&quot; A Coordinate Dialog Module.</span>

<span class="sd">The CoordDialog class handles a dialog for converting coordinate pairs or files</span>
<span class="sd">from one Datum / Projection to another interactively.</span>

<span class="sd">    :Author:</span>
<span class="sd">      - 20111227-20120111 Roberto Vidmar</span>

<span class="sd">    :Revision:  $Revision: 52 $</span>
<span class="sd">                $Date: 2012-11-12 10:07:15 +0100 (Mon, 12 Nov 2012) $</span>

<span class="sd">    :Copyright: 2011-2012</span>
<span class="sd">                Nicola Creati &lt;ncreati@inogs.it&gt;</span>
<span class="sd">                Roberto Vidmar &lt;rvidmar@inogs.it&gt;</span>

<span class="sd">    :License: MIT/X11 License (see :download:`license.txt</span>
<span class="sd">                               &lt;../../license.txt&gt;`)</span>
<span class="sd">&quot;&quot;&quot;</span>

<span class="kn">import</span> <span class="nn">sys</span>
<span class="kn">import</span> <span class="nn">codecs</span>
<span class="kn">import</span> <span class="nn">time</span>
<span class="kn">import</span> <span class="nn">numpy</span> <span class="kn">as</span> <span class="nn">np</span>

<span class="kn">from</span> <span class="nn">pyproj</span> <span class="kn">import</span> <span class="n">Proj</span><span class="p">,</span> <span class="n">transform</span>
<span class="kn">from</span> <span class="nn">qtCompat</span> <span class="kn">import</span> <span class="n">Qt</span><span class="p">,</span> <span class="n">QtCore</span><span class="p">,</span> <span class="n">QtGui</span>

<span class="n">QCA</span> <span class="o">=</span> <span class="n">QtCore</span><span class="o">.</span><span class="n">QCoreApplication</span>
<span class="kn">import</span> <span class="nn">icons_rc</span>
<span class="kn">from</span> <span class="nn">degrees</span> <span class="kn">import</span> <span class="n">d2dm</span><span class="p">,</span> <span class="n">d2dms</span>
<span class="kn">from</span> <span class="nn">coordWidget</span> <span class="kn">import</span> <span class="n">CoordWidget</span>
<span class="kn">from</span> <span class="nn">filePicker</span> <span class="kn">import</span> <span class="n">FilePicker</span>
<span class="kn">from</span> <span class="nn">fieldsWizard</span> <span class="kn">import</span> <span class="n">FieldsWizard</span><span class="p">,</span> <span class="n">readASCII</span>
<span class="kn">from</span> <span class="nn">progressDialog</span> <span class="kn">import</span> <span class="n">ProgressDialog</span><span class="p">,</span> <span class="n">ThreadedFunc</span>

<span class="n">Revision</span> <span class="o">=</span> <span class="s">&#39;$Revision: 52 $&#39;</span>

<div class="viewcode-block" id="unimplemented"><a class="viewcode-back" href="../../ccqw.html#ccqw.coordDialog.unimplemented">[docs]</a><span class="k">def</span> <span class="nf">unimplemented</span><span class="p">():</span>
  <span class="sd">&quot;&quot;&quot; Display an &#39;Unimplemented&#39; message</span>
<span class="sd">  &quot;&quot;&quot;</span>
  <span class="n">mbox</span> <span class="o">=</span> <span class="n">QtGui</span><span class="o">.</span><span class="n">QMessageBox</span><span class="p">()</span>
  <span class="n">mbox</span><span class="o">.</span><span class="n">setWindowTitle</span><span class="p">(</span><span class="n">QCA</span><span class="o">.</span><span class="n">translate</span><span class="p">(</span><span class="s">&quot;UnimplementedMessage&quot;</span><span class="p">,</span> <span class="s">&#39;Unimplemented&#39;</span><span class="p">))</span>
  <span class="n">mbox</span><span class="o">.</span><span class="n">setIcon</span><span class="p">(</span><span class="n">QtGui</span><span class="o">.</span><span class="n">QMessageBox</span><span class="o">.</span><span class="n">Information</span><span class="p">)</span>
  <span class="n">mbox</span><span class="o">.</span><span class="n">setInformativeText</span><span class="p">(</span><span class="n">QCA</span><span class="o">.</span><span class="n">translate</span><span class="p">(</span><span class="s">&quot;UnimplementedMessage&quot;</span><span class="p">,</span>
    <span class="s">&quot;This conversion has not been</span><span class="se">\n</span><span class="s">&quot;</span>
    <span class="s">&quot;implemented yet.&quot;</span><span class="p">))</span>
  <span class="n">mbox</span><span class="o">.</span><span class="n">setStandardButtons</span><span class="p">(</span><span class="n">QtGui</span><span class="o">.</span><span class="n">QMessageBox</span><span class="o">.</span><span class="n">Ok</span><span class="p">)</span>
  <span class="n">mbox</span><span class="o">.</span><span class="n">setDefaultButton</span><span class="p">(</span><span class="n">QtGui</span><span class="o">.</span><span class="n">QMessageBox</span><span class="o">.</span><span class="n">Ok</span><span class="p">)</span>
  <span class="n">mbox</span><span class="o">.</span><span class="n">button</span><span class="p">(</span><span class="n">QtGui</span><span class="o">.</span><span class="n">QMessageBox</span><span class="o">.</span><span class="n">Ok</span><span class="p">)</span><span class="o">.</span><span class="n">setText</span><span class="p">(</span>
    <span class="n">QCA</span><span class="o">.</span><span class="n">translate</span><span class="p">(</span><span class="s">&quot;UnimplementedMessage&quot;</span><span class="p">,</span> <span class="s">&#39;Ok&#39;</span><span class="p">))</span>
  <span class="n">mbox</span><span class="o">.</span><span class="n">exec_</span><span class="p">()</span>
</div>
<div class="viewcode-block" id="noDatumShift"><a class="viewcode-back" href="../../ccqw.html#ccqw.coordDialog.noDatumShift">[docs]</a><span class="k">def</span> <span class="nf">noDatumShift</span><span class="p">((</span><span class="n">phi</span><span class="p">,</span> <span class="n">lamda</span><span class="p">)):</span>
  <span class="sd">&quot;&quot;&quot; Display a &#39;noDatumShift&#39; message</span>
<span class="sd">  &quot;&quot;&quot;</span>
  <span class="n">utfCodec</span> <span class="o">=</span> <span class="n">QtCore</span><span class="o">.</span><span class="n">QTextCodec</span><span class="o">.</span><span class="n">codecForName</span><span class="p">(</span><span class="s">&quot;UTF-8&quot;</span><span class="p">)</span>
  <span class="n">QtCore</span><span class="o">.</span><span class="n">QTextCodec</span><span class="o">.</span><span class="n">setCodecForTr</span><span class="p">(</span><span class="n">utfCodec</span><span class="p">);</span>
  <span class="n">mbox</span> <span class="o">=</span> <span class="n">QtGui</span><span class="o">.</span><span class="n">QMessageBox</span><span class="p">()</span>
  <span class="n">mbox</span><span class="o">.</span><span class="n">setWindowTitle</span><span class="p">(</span><span class="n">QCA</span><span class="o">.</span><span class="n">translate</span><span class="p">(</span><span class="s">&quot;noDatumShift&quot;</span><span class="p">,</span> <span class="s">&#39;No Datum Shift&#39;</span><span class="p">))</span>
  <span class="n">mbox</span><span class="o">.</span><span class="n">setIcon</span><span class="p">(</span><span class="n">QtGui</span><span class="o">.</span><span class="n">QMessageBox</span><span class="o">.</span><span class="n">Information</span><span class="p">)</span>
  <span class="n">mbox</span><span class="o">.</span><span class="n">setInformativeText</span><span class="p">(</span><span class="n">QCA</span><span class="o">.</span><span class="n">translate</span><span class="p">(</span><span class="s">&quot;noDatumShift&quot;</span><span class="p">,</span>
    <span class="s">&quot;Datum shift matrix is undefined in</span><span class="se">\n</span><span class="s">&quot;</span>
    <span class="s">&quot;φ = </span><span class="si">%.9f</span><span class="s"> λ = </span><span class="si">%.9f</span><span class="s">.&quot;</span> <span class="o">%</span> <span class="p">(</span><span class="n">phi</span><span class="p">,</span> <span class="n">lamda</span><span class="p">)))</span>
  <span class="n">mbox</span><span class="o">.</span><span class="n">setStandardButtons</span><span class="p">(</span><span class="n">QtGui</span><span class="o">.</span><span class="n">QMessageBox</span><span class="o">.</span><span class="n">Ok</span><span class="p">)</span>
  <span class="n">mbox</span><span class="o">.</span><span class="n">setDefaultButton</span><span class="p">(</span><span class="n">QtGui</span><span class="o">.</span><span class="n">QMessageBox</span><span class="o">.</span><span class="n">Ok</span><span class="p">)</span>
  <span class="n">mbox</span><span class="o">.</span><span class="n">button</span><span class="p">(</span><span class="n">QtGui</span><span class="o">.</span><span class="n">QMessageBox</span><span class="o">.</span><span class="n">Ok</span><span class="p">)</span><span class="o">.</span><span class="n">setText</span><span class="p">(</span>
    <span class="n">QCA</span><span class="o">.</span><span class="n">translate</span><span class="p">(</span><span class="s">&quot;noDatumShift&quot;</span><span class="p">,</span> <span class="s">&#39;Ok&#39;</span><span class="p">))</span>
  <span class="n">mbox</span><span class="o">.</span><span class="n">exec_</span><span class="p">()</span>
</div>
<div class="viewcode-block" id="writeASCII"><a class="viewcode-back" href="../../ccqw.html#ccqw.coordDialog.writeASCII">[docs]</a><span class="k">def</span> <span class="nf">writeASCII</span><span class="p">(</span><span class="n">progress</span><span class="p">,</span> <span class="n">quitFunc</span><span class="p">,</span> <span class="n">pn</span><span class="p">,</span> <span class="n">xyz</span><span class="p">,</span> <span class="n">fmt</span><span class="p">,</span> <span class="n">header</span><span class="o">=</span><span class="s">&#39;&#39;</span><span class="p">,</span>
  <span class="n">recsPerChunk</span><span class="o">=</span><span class="mi">1000000</span><span class="p">):</span>
  <span class="sd">&quot;&quot;&quot; Write xyz (n x npoints) to ASCII File pn in chunks with optional Header</span>

<span class="sd">    :param progress: progress function. This funtion is called at every step.</span>
<span class="sd">    :type progress: function</span>
<span class="sd">    :param quitFunc: quit function. This funtion is called at every step and if</span>
<span class="sd">                     it returns True it&#39;s time to quit.</span>
<span class="sd">    :type quitFunc: function</span>
<span class="sd">    :param pn: pathname of the file to write</span>
<span class="sd">    :type pn: string, unicode</span>
<span class="sd">    :param xyz: dataset to write</span>
<span class="sd">    :type xyz: numpy array 3xN</span>
<span class="sd">    :param fmt: format to use to output data to ASCII</span>
<span class="sd">    :type fmt: string</span>
<span class="sd">    :param header: optional header</span>
<span class="sd">    :type header: string</span>
<span class="sd">    :param recsPerChunk: number of records to write at every iteration (chunk)</span>
<span class="sd">    :type recsPerChunk: int</span>
<span class="sd">    :raises:</span>
<span class="sd">  &quot;&quot;&quot;</span>
  <span class="c"># Write coordinates to output</span>
  <span class="n">fid</span> <span class="o">=</span> <span class="n">codecs</span><span class="o">.</span><span class="n">open</span><span class="p">(</span><span class="n">pn</span><span class="p">,</span> <span class="s">&quot;w&quot;</span><span class="p">,</span> <span class="s">&#39;UTF-8&#39;</span><span class="p">)</span>

  <span class="c"># Write an optional header</span>
  <span class="k">if</span> <span class="n">header</span><span class="p">:</span>
    <span class="n">fid</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="n">header</span><span class="p">)</span>

  <span class="n">recsWritten</span> <span class="o">=</span> <span class="mi">0</span>
  <span class="n">recsToWrite</span> <span class="o">=</span> <span class="n">xyz</span><span class="o">.</span><span class="n">shape</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span>
  <span class="n">remainingRecords</span> <span class="o">=</span> <span class="n">recsToWrite</span>
  <span class="k">while</span> <span class="n">remainingRecords</span><span class="p">:</span>
    <span class="c"># Adjust recsPerChunk</span>
    <span class="n">recsPerChunk</span> <span class="o">=</span> <span class="nb">min</span><span class="p">(</span><span class="n">recsPerChunk</span><span class="p">,</span> <span class="n">remainingRecords</span><span class="p">)</span>
    <span class="n">start</span> <span class="o">=</span> <span class="n">recsToWrite</span> <span class="o">-</span> <span class="n">remainingRecords</span>
    <span class="n">end</span> <span class="o">=</span> <span class="n">start</span> <span class="o">+</span> <span class="n">recsPerChunk</span>

    <span class="c"># Black Magic...</span>
    <span class="n">values</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">ravel</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">vstack</span><span class="p">((</span><span class="n">c</span><span class="p">[</span><span class="n">start</span><span class="p">:</span> <span class="n">end</span><span class="p">]</span> <span class="k">for</span> <span class="n">c</span> <span class="ow">in</span> <span class="n">xyz</span><span class="p">))</span><span class="o">.</span><span class="n">T</span><span class="p">)</span>
    <span class="n">chunk</span> <span class="o">=</span> <span class="n">fmt</span> <span class="o">*</span> <span class="n">recsPerChunk</span> <span class="o">%</span> <span class="nb">tuple</span><span class="p">(</span><span class="n">values</span><span class="p">)</span>
    <span class="n">fid</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="n">chunk</span><span class="p">)</span>

    <span class="c"># Save number of records actually read</span>
    <span class="n">recsWritten</span> <span class="o">+=</span> <span class="n">recsPerChunk</span>
    <span class="n">remainingRecords</span> <span class="o">-=</span> <span class="n">recsPerChunk</span>
    <span class="c"># Memory mapped array?</span>
    <span class="c">#if hasattr(points, &#39;flush&#39;):</span>
    <span class="c">#  points.flush()</span>
    <span class="k">if</span> <span class="n">quitFunc</span><span class="p">():</span>
      <span class="k">break</span>
    <span class="n">pcent</span> <span class="o">=</span> <span class="mf">100.</span> <span class="o">*</span> <span class="n">recsWritten</span> <span class="o">/</span> <span class="n">recsToWrite</span>
    <span class="n">progress</span><span class="p">(</span><span class="n">pcent</span><span class="p">)</span>
  <span class="n">fid</span><span class="o">.</span><span class="n">close</span><span class="p">()</span>

<span class="c">#===============================================================================</span></div>
<div class="viewcode-block" id="CoordDialog"><a class="viewcode-back" href="../../ccqw.html#ccqw.coordDialog.CoordDialog">[docs]</a><span class="k">class</span> <span class="nc">CoordDialog</span><span class="p">(</span><span class="n">QtGui</span><span class="o">.</span><span class="n">QDialog</span><span class="p">):</span>
  <span class="sd">&quot;&quot;&quot; A coordinates dialog class to represent a 3D point in two different</span>
<span class="sd">      datums and projections.</span>

<span class="sd">      The dialog support also conversion of files.</span>

<span class="sd">    :Author: R. Vidmar, 20111227</span>
<span class="sd">  &quot;&quot;&quot;</span>
  <span class="n">ModePoint</span> <span class="o">=</span> <span class="mi">0</span>
  <span class="n">ModeFile</span> <span class="o">=</span> <span class="mi">1</span>

<div class="viewcode-block" id="CoordDialog.__init__"><a class="viewcode-back" href="../../ccqw.html#ccqw.coordDialog.CoordDialog.__init__">[docs]</a>  <span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">xyz</span><span class="p">,</span> <span class="n">projFrom</span><span class="o">=</span><span class="n">CoordWidget</span><span class="o">.</span><span class="n">WGS84</span><span class="p">,</span> <span class="n">projTo</span><span class="o">=</span><span class="n">CoordWidget</span><span class="o">.</span><span class="n">WGS84</span><span class="p">,</span>
    <span class="n">ell2Ortho</span><span class="o">=</span><span class="bp">None</span><span class="p">,</span> <span class="n">name</span><span class="o">=</span><span class="s">&#39;&#39;</span><span class="p">,</span> <span class="n">upperMode</span><span class="o">=</span><span class="n">CoordWidget</span><span class="o">.</span><span class="n">ModeD</span><span class="p">,</span>
    <span class="n">lowerMode</span><span class="o">=</span><span class="n">CoordWidget</span><span class="o">.</span><span class="n">ModeDMS</span><span class="p">,</span> <span class="n">dmsChars</span><span class="o">=</span><span class="p">[</span><span class="s">u&quot;°&quot;</span><span class="p">,</span> <span class="s">u&quot;&#39;&quot;</span><span class="p">,</span> <span class="s">u&#39;&quot;&#39;</span><span class="p">],</span> <span class="n">parent</span><span class="o">=</span><span class="bp">None</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot; Create a new CoordDialog instance.</span>

<span class="sd">        :param xyz: Tuple (x, y, z) where: x = Easting or longitude,</span>
<span class="sd">                    y = Northing or latitude, z = Ellipsoidical height</span>
<span class="sd">        :type xyz: tuple</span>
<span class="sd">        :param projFrom: PROJ.4 string defining x, y, z</span>
<span class="sd">        :type projFrom: string</span>
<span class="sd">        :param projTo: PROJ.4 string defining the new datum/projection</span>
<span class="sd">        :type projTo: string</span>
<span class="sd">        :param ell2Ortho: offset to add to z to obtain orthometric height</span>
<span class="sd">        :type ell2Ortho: float</span>
<span class="sd">        :param name: optional name of this point</span>
<span class="sd">        :type name: string, unicode</span>
<span class="sd">        :param upperMode: mode at init: (0, ... CoordWidget.ModeFile) for the</span>
<span class="sd">                          upper coordWidget</span>
<span class="sd">        :type upperMode: int</span>
<span class="sd">        :param lowerMode: mode at init: (0, ... CoordWidget.ModeFile) for the</span>
<span class="sd">                          lower coordWidget</span>
<span class="sd">        :type lowerMode: int</span>
<span class="sd">        :param dmsChars: Separators for degrees, minutes, seconds</span>
<span class="sd">                         ([u&quot;°&quot;, u&quot;&#39;&quot;, u&#39;&quot;&#39;])</span>
<span class="sd">        :type dmsChars: tuple</span>
<span class="sd">        :param parent: parent widget</span>
<span class="sd">        :type parent: QtGui widget</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="nb">super</span><span class="p">(</span><span class="n">CoordDialog</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="n">__init__</span><span class="p">(</span><span class="n">parent</span><span class="p">)</span>

    <span class="bp">self</span><span class="o">.</span><span class="n">setWindowTitle</span><span class="p">(</span><span class="n">QCA</span><span class="o">.</span><span class="n">translate</span><span class="p">(</span><span class="s">&quot;coordDialog&quot;</span><span class="p">,</span>
      <span class="s">&quot;Proj.4 Coordinate Converter - Rev. </span><span class="si">%s</span><span class="s">&quot;</span><span class="p">)</span> <span class="o">%</span> <span class="n">Revision</span><span class="o">.</span><span class="n">split</span><span class="p">()[</span><span class="mi">1</span><span class="p">])</span>
    <span class="k">if</span> <span class="n">name</span><span class="p">:</span>
      <span class="bp">self</span><span class="o">.</span><span class="n">setObjectName</span><span class="p">(</span><span class="n">name</span><span class="p">)</span>
      <span class="n">pointLabel</span> <span class="o">=</span> <span class="n">QtGui</span><span class="o">.</span><span class="n">QLabel</span><span class="p">(</span><span class="n">name</span><span class="p">)</span>
      <span class="n">f</span> <span class="o">=</span> <span class="n">pointLabel</span><span class="o">.</span><span class="n">font</span><span class="p">()</span>
      <span class="n">f</span><span class="o">.</span><span class="n">setBold</span><span class="p">(</span><span class="bp">True</span><span class="p">)</span>
      <span class="n">pointLabel</span><span class="o">.</span><span class="n">setFont</span><span class="p">(</span><span class="n">f</span><span class="p">)</span>
      <span class="n">pointLabel</span><span class="o">.</span><span class="n">setToolTip</span><span class="p">(</span><span class="n">QCA</span><span class="o">.</span><span class="n">translate</span><span class="p">(</span><span class="s">&quot;coordDialog&quot;</span><span class="p">,</span>
        <span class="s">&quot;The name of this point&quot;</span><span class="p">))</span>
    <span class="k">else</span><span class="p">:</span>
      <span class="n">pointLabel</span> <span class="o">=</span> <span class="bp">None</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">inC</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">outC</span> <span class="o">=</span> <span class="bp">None</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">_lastInputFilePath</span> <span class="o">=</span> <span class="bp">None</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">_dmsChars</span> <span class="o">=</span> <span class="n">dmsChars</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">_logo1</span> <span class="o">=</span> <span class="n">QtGui</span><span class="o">.</span><span class="n">QImage</span><span class="p">(</span><span class="s">&quot;:/BoboAndNick.png&quot;</span> <span class="p">)</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">_logo2</span> <span class="o">=</span> <span class="n">QtGui</span><span class="o">.</span><span class="n">QImage</span><span class="p">(</span><span class="s">&quot;:/logo.png&quot;</span><span class="p">)</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">_logo</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_logo2</span>

    <span class="n">labels</span> <span class="o">=</span> <span class="p">(</span>
      <span class="s">u&quot;</span><span class="se">\N{GREEK SMALL LETTER PHI}</span><span class="s">&quot;</span><span class="p">,</span> <span class="s">u&quot;</span><span class="se">\N{GREEK SMALL LETTER LAMDA}</span><span class="s">&quot;</span><span class="p">,</span>
      <span class="n">QCA</span><span class="o">.</span><span class="n">translate</span><span class="p">(</span><span class="s">&quot;CoordWidget&quot;</span><span class="p">,</span> <span class="s">&quot;H&quot;</span><span class="p">),</span>
      <span class="n">QCA</span><span class="o">.</span><span class="n">translate</span><span class="p">(</span><span class="s">&quot;CoordWidget&quot;</span><span class="p">,</span> <span class="s">&quot;E&quot;</span><span class="p">),</span>
      <span class="n">QCA</span><span class="o">.</span><span class="n">translate</span><span class="p">(</span><span class="s">&quot;CoordWidget&quot;</span><span class="p">,</span> <span class="s">&quot;N&quot;</span><span class="p">),</span>
      <span class="n">QCA</span><span class="o">.</span><span class="n">translate</span><span class="p">(</span><span class="s">&quot;CoordWidget&quot;</span><span class="p">,</span> <span class="s">&quot;Input File&quot;</span><span class="p">),</span>
      <span class="n">QCA</span><span class="o">.</span><span class="n">translate</span><span class="p">(</span><span class="s">&quot;CoordWidget&quot;</span><span class="p">,</span> <span class="s">&quot;Output File&quot;</span><span class="p">))</span>

    <span class="k">if</span> <span class="n">lowerMode</span> <span class="o">==</span> <span class="n">CoordWidget</span><span class="o">.</span><span class="n">ModeFile</span> <span class="ow">or</span> <span class="n">upperMode</span> <span class="o">==</span> <span class="n">CoordWidget</span><span class="o">.</span><span class="n">ModeFile</span><span class="p">:</span>
      <span class="bp">self</span><span class="o">.</span><span class="n">_fileMode</span> <span class="o">=</span> <span class="bp">True</span>
    <span class="k">else</span><span class="p">:</span>
      <span class="bp">self</span><span class="o">.</span><span class="n">_fileMode</span> <span class="o">=</span> <span class="bp">False</span>
    <span class="n">cWidget1</span> <span class="o">=</span> <span class="n">CoordWidget</span><span class="p">(</span><span class="n">xyz</span><span class="p">,</span> <span class="n">proj</span><span class="o">=</span><span class="n">projFrom</span><span class="p">,</span> <span class="n">ell2Ortho</span><span class="o">=</span><span class="n">ell2Ortho</span><span class="p">,</span>
      <span class="n">name</span><span class="o">=</span><span class="s">&#39;Upper&#39;</span><span class="p">,</span> <span class="n">comboU</span><span class="o">=</span><span class="s">&#39;File&#39;</span><span class="p">,</span> <span class="n">labels</span><span class="o">=</span><span class="n">labels</span><span class="p">,</span> <span class="n">initMode</span><span class="o">=</span><span class="n">upperMode</span><span class="p">)</span>
    <span class="n">cWidget1</span><span class="o">.</span><span class="n">changedSignal</span><span class="o">.</span><span class="n">connect</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">changed</span><span class="p">)</span>

    <span class="n">cWidget2</span> <span class="o">=</span> <span class="n">CoordWidget</span><span class="p">(</span><span class="n">proj</span><span class="o">=</span><span class="n">projTo</span><span class="p">,</span>
      <span class="n">name</span><span class="o">=</span><span class="s">&#39;Lower&#39;</span><span class="p">,</span> <span class="n">comboU</span><span class="o">=</span><span class="s">&#39;File&#39;</span><span class="p">,</span> <span class="n">labels</span><span class="o">=</span><span class="n">labels</span><span class="p">,</span> <span class="n">initMode</span><span class="o">=</span><span class="n">lowerMode</span><span class="p">)</span>
    <span class="n">cWidget2</span><span class="o">.</span><span class="n">changedSignal</span><span class="o">.</span><span class="n">connect</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">changed</span><span class="p">)</span>

    <span class="n">cWidget2</span><span class="o">.</span><span class="n">setValue</span><span class="p">(</span><span class="o">*</span><span class="n">transform</span><span class="p">(</span>
      <span class="n">cWidget1</span><span class="o">.</span><span class="n">proj</span><span class="p">(),</span> <span class="n">cWidget2</span><span class="o">.</span><span class="n">proj</span><span class="p">(),</span> <span class="o">*</span><span class="n">cWidget1</span><span class="o">.</span><span class="n">xyz</span><span class="p">()))</span>
    <span class="n">cWidget2</span><span class="o">.</span><span class="n">setEll2Ortho</span><span class="p">(</span><span class="n">cWidget1</span><span class="o">.</span><span class="n">ell2Ortho</span><span class="p">())</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">cWidgets</span> <span class="o">=</span> <span class="p">[</span><span class="n">cWidget1</span><span class="p">,</span> <span class="n">cWidget2</span><span class="p">]</span>

    <span class="c"># The &quot;CONVERT FILE&quot; button</span>
    <span class="n">btn</span> <span class="o">=</span> <span class="n">QtGui</span><span class="o">.</span><span class="n">QPushButton</span><span class="p">(</span><span class="n">QCA</span><span class="o">.</span><span class="n">translate</span><span class="p">(</span><span class="s">&quot;Convert Button&quot;</span><span class="p">,</span> <span class="s">&quot;Convert File&quot;</span><span class="p">))</span>
    <span class="n">btn</span><span class="o">.</span><span class="n">setToolTip</span><span class="p">(</span><span class="n">QCA</span><span class="o">.</span><span class="n">translate</span><span class="p">(</span><span class="s">&quot;Convert Button&quot;</span><span class="p">,</span>
      <span class="s">&quot;Click here to convert input File&quot;</span><span class="p">))</span>
    <span class="n">bsize</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_logo2</span><span class="o">.</span><span class="n">size</span><span class="p">()</span>
    <span class="n">bsize</span><span class="o">.</span><span class="n">scale</span><span class="p">(</span><span class="mi">100</span><span class="p">,</span> <span class="mi">90</span><span class="p">,</span> <span class="n">Qt</span><span class="o">.</span><span class="n">KeepAspectRatio</span><span class="p">)</span>
    <span class="n">btn</span><span class="o">.</span><span class="n">setFixedWidth</span><span class="p">(</span><span class="n">bsize</span><span class="o">.</span><span class="n">width</span><span class="p">());</span>
    <span class="n">btn</span><span class="o">.</span><span class="n">setFixedHeight</span><span class="p">(</span><span class="n">bsize</span><span class="o">.</span><span class="n">height</span><span class="p">());</span>
    <span class="n">padx</span> <span class="o">=</span> <span class="mi">5</span>
    <span class="n">pady</span> <span class="o">=</span> <span class="mi">10</span>
    <span class="n">region</span> <span class="o">=</span> <span class="n">QtGui</span><span class="o">.</span><span class="n">QRegion</span><span class="p">(</span><span class="n">QtCore</span><span class="o">.</span><span class="n">QRect</span><span class="p">(</span>
      <span class="n">btn</span><span class="o">.</span><span class="n">x</span><span class="p">()</span> <span class="o">+</span> <span class="n">padx</span><span class="p">,</span> <span class="n">btn</span><span class="o">.</span><span class="n">y</span><span class="p">()</span> <span class="o">+</span> <span class="n">pady</span><span class="p">,</span>
      <span class="n">btn</span><span class="o">.</span><span class="n">width</span><span class="p">()</span> <span class="o">-</span> <span class="mi">2</span> <span class="o">*</span> <span class="n">padx</span><span class="p">,</span> <span class="n">btn</span><span class="o">.</span><span class="n">height</span><span class="p">()</span> <span class="o">-</span> <span class="mi">2</span> <span class="o">*</span> <span class="n">pady</span><span class="p">),</span> <span class="n">QtGui</span><span class="o">.</span><span class="n">QRegion</span><span class="o">.</span><span class="n">Ellipse</span><span class="p">)</span>
    <span class="n">btn</span><span class="o">.</span><span class="n">setMask</span><span class="p">(</span><span class="n">region</span><span class="p">)</span>
    <span class="n">btn</span><span class="o">.</span><span class="n">setStyleSheet</span><span class="p">(</span><span class="s">&quot;&quot;&quot;</span>
<span class="s">      QPushButton {</span>
<span class="s">        border: 2px solid #8f8f91;</span>
<span class="s">        border-radius: 10px;</span>
<span class="s">        color: white;</span>
<span class="s">        font-weight: bold;</span>
<span class="s">        background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 1,</span>
<span class="s">                                       stop: 0 #D1D0E2, stop: 1 #383481);</span>
<span class="s">        min-width: 100px;</span>
<span class="s">      }</span>
<span class="s">      QPushButton:pressed {</span>
<span class="s">        background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 1,</span>
<span class="s">                                       stop: 0 #383481, stop: 1 #D1D0E2);</span>
<span class="s">      }</span>

<span class="s">      QPushButton:flat {</span>
<span class="s">        border: none; /* no border for a flat push button */</span>
<span class="s">      }</span>

<span class="s">      QPushButton:default {</span>
<span class="s">       border-color: navy;</span>
<span class="s">      }&quot;&quot;&quot;</span><span class="p">)</span>
    <span class="n">btn</span><span class="o">.</span><span class="n">clicked</span><span class="o">.</span><span class="n">connect</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_onConvertBtn</span><span class="p">)</span>
    <span class="n">btn</span><span class="o">.</span><span class="n">setHidden</span><span class="p">(</span><span class="bp">True</span><span class="p">)</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">convertBtn</span> <span class="o">=</span> <span class="n">btn</span>

    <span class="n">layout</span> <span class="o">=</span> <span class="n">QtGui</span><span class="o">.</span><span class="n">QVBoxLayout</span><span class="p">()</span>
    <span class="k">if</span> <span class="n">pointLabel</span><span class="p">:</span>
      <span class="n">layout</span><span class="o">.</span><span class="n">addWidget</span><span class="p">(</span><span class="n">pointLabel</span><span class="p">,</span> <span class="n">alignment</span><span class="o">=</span><span class="n">Qt</span><span class="o">.</span><span class="n">AlignJustify</span><span class="p">)</span>
    <span class="n">layout</span><span class="o">.</span><span class="n">addWidget</span><span class="p">(</span><span class="n">cWidget1</span><span class="p">)</span>
    <span class="n">layout</span><span class="o">.</span><span class="n">addWidget</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">convertBtn</span><span class="p">,</span> <span class="n">alignment</span><span class="o">=</span><span class="n">Qt</span><span class="o">.</span><span class="n">AlignCenter</span><span class="p">)</span>
    <span class="n">layout</span><span class="o">.</span><span class="n">addWidget</span><span class="p">(</span><span class="n">cWidget2</span><span class="p">)</span>
    <span class="n">layout</span><span class="o">.</span><span class="n">addStretch</span><span class="p">(</span><span class="mi">0</span><span class="p">)</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">setLayout</span><span class="p">(</span><span class="n">layout</span><span class="p">)</span>

    <span class="c"># Hidden key ;-)</span>
    <span class="n">QtGui</span><span class="o">.</span><span class="n">QShortcut</span><span class="p">(</span><span class="n">QtGui</span><span class="o">.</span><span class="n">QKeySequence</span><span class="p">(</span><span class="s">&quot;Ctrl+H&quot;</span><span class="p">),</span> <span class="bp">self</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_hiddenKey</span><span class="p">)</span>
</div>
<div class="viewcode-block" id="CoordDialog.resizeEvent"><a class="viewcode-back" href="../../ccqw.html#ccqw.coordDialog.CoordDialog.resizeEvent">[docs]</a>  <span class="k">def</span> <span class="nf">resizeEvent</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">evt</span><span class="p">):</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">backGround</span> <span class="o">=</span> <span class="n">QtGui</span><span class="o">.</span><span class="n">QImage</span><span class="p">(</span><span class="n">evt</span><span class="o">.</span><span class="n">size</span><span class="p">(),</span>
      <span class="n">QtGui</span><span class="o">.</span><span class="n">QImage</span><span class="o">.</span><span class="n">Format_ARGB32_Premultiplied</span><span class="p">)</span>
    <span class="n">p</span> <span class="o">=</span> <span class="n">QtGui</span><span class="o">.</span><span class="n">QPainter</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">backGround</span><span class="p">)</span>
    <span class="n">p</span><span class="o">.</span><span class="n">fillRect</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">backGround</span><span class="o">.</span><span class="n">rect</span><span class="p">(),</span> <span class="n">QtGui</span><span class="o">.</span><span class="n">QColor</span><span class="p">(</span><span class="mi">222</span><span class="p">,</span> <span class="mi">222</span><span class="p">,</span> <span class="mi">222</span><span class="p">))</span>
    <span class="n">scaled</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_logo</span><span class="o">.</span><span class="n">scaled</span><span class="p">(</span><span class="n">evt</span><span class="o">.</span><span class="n">size</span><span class="p">(),</span> <span class="n">Qt</span><span class="o">.</span><span class="n">KeepAspectRatio</span><span class="p">)</span>
    <span class="n">scaledRect</span> <span class="o">=</span> <span class="n">scaled</span><span class="o">.</span><span class="n">rect</span><span class="p">()</span>
    <span class="n">scaledRect</span><span class="o">.</span><span class="n">moveCenter</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">backGround</span><span class="o">.</span><span class="n">rect</span><span class="p">()</span><span class="o">.</span><span class="n">center</span><span class="p">())</span>
    <span class="n">p</span><span class="o">.</span><span class="n">drawImage</span><span class="p">(</span><span class="n">scaledRect</span><span class="p">,</span> <span class="n">scaled</span><span class="p">)</span>

    <span class="n">palette</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">palette</span><span class="p">()</span>
    <span class="n">brush</span> <span class="o">=</span> <span class="n">QtGui</span><span class="o">.</span><span class="n">QBrush</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">backGround</span><span class="p">)</span>
    <span class="n">palette</span><span class="o">.</span><span class="n">setBrush</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">backgroundRole</span><span class="p">(),</span> <span class="n">brush</span><span class="p">)</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">setPalette</span><span class="p">(</span><span class="n">palette</span><span class="p">)</span>
    <span class="nb">super</span><span class="p">(</span><span class="n">CoordDialog</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="n">resizeEvent</span><span class="p">(</span><span class="n">evt</span><span class="p">)</span>
</div>
  <span class="k">def</span> <span class="nf">_hiddenKey</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot; Some credits to the authors...</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_logo</span> <span class="o">==</span> <span class="bp">self</span><span class="o">.</span><span class="n">_logo1</span><span class="p">:</span>
      <span class="bp">self</span><span class="o">.</span><span class="n">_logo</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_logo2</span>
    <span class="k">else</span><span class="p">:</span>
      <span class="bp">self</span><span class="o">.</span><span class="n">_logo</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_logo1</span>
    <span class="n">size</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">size</span><span class="p">()</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">resizeEvent</span><span class="p">(</span><span class="n">QtGui</span><span class="o">.</span><span class="n">QResizeEvent</span><span class="p">(</span><span class="n">size</span><span class="p">,</span> <span class="n">size</span><span class="p">))</span>

  <span class="k">def</span> <span class="nf">_onConvertBtn</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
    <span class="n">w1</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">cWidgets</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
    <span class="n">w2</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">cWidgets</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span>

    <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">cWidgets</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">filePath</span><span class="p">()</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">cWidgets</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">filePath</span><span class="p">():</span>
      <span class="c"># Both input and output files defined and valid; convert?</span>
      <span class="k">for</span> <span class="n">c</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">cWidgets</span><span class="p">:</span>
        <span class="k">if</span> <span class="n">c</span><span class="o">.</span><span class="n">filePickerMode</span><span class="p">()</span> <span class="o">==</span> <span class="n">FilePicker</span><span class="o">.</span><span class="n">OutputMode</span><span class="p">:</span>
          <span class="c"># This is output</span>
          <span class="n">outC</span> <span class="o">=</span> <span class="n">c</span>
        <span class="k">else</span><span class="p">:</span>
          <span class="n">inC</span> <span class="o">=</span> <span class="n">c</span>
      <span class="n">msgBox</span> <span class="o">=</span> <span class="n">QtGui</span><span class="o">.</span><span class="n">QMessageBox</span><span class="p">(</span><span class="n">QtGui</span><span class="o">.</span><span class="n">QMessageBox</span><span class="o">.</span><span class="n">Question</span><span class="p">,</span>
        <span class="n">QCA</span><span class="o">.</span><span class="n">translate</span><span class="p">(</span><span class="s">&quot;Ok to convert&quot;</span><span class="p">,</span> <span class="s">&#39;Convert File&#39;</span><span class="p">),</span>
        <span class="n">QCA</span><span class="o">.</span><span class="n">translate</span><span class="p">(</span><span class="s">&quot;Ok to convert&quot;</span><span class="p">,</span>
          <span class="s">&quot;Ok to convert</span><span class="se">\n</span><span class="s">&#39;</span><span class="si">%s</span><span class="s">&#39; to</span><span class="se">\n</span><span class="s">&#39;</span><span class="si">%s</span><span class="s">&#39;</span><span class="se">\n</span><span class="s">with format &#39;</span><span class="si">%s</span><span class="s">&#39; ?&quot;</span><span class="p">)</span> <span class="o">%</span>
          <span class="p">(</span><span class="n">inC</span><span class="o">.</span><span class="n">filePath</span><span class="p">(),</span> <span class="n">outC</span><span class="o">.</span><span class="n">filePath</span><span class="p">(),</span>  <span class="n">outC</span><span class="o">.</span><span class="n">coordFormat</span><span class="p">()),</span>
        <span class="n">QtGui</span><span class="o">.</span><span class="n">QMessageBox</span><span class="o">.</span><span class="n">Ok</span><span class="o">|</span><span class="n">QtGui</span><span class="o">.</span><span class="n">QMessageBox</span><span class="o">.</span><span class="n">Cancel</span><span class="p">)</span>
      <span class="k">if</span> <span class="n">msgBox</span><span class="o">.</span><span class="n">exec_</span><span class="p">()</span> <span class="o">==</span> <span class="n">QtGui</span><span class="o">.</span><span class="n">QMessageBox</span><span class="o">.</span><span class="n">Ok</span><span class="p">:</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">inC</span> <span class="o">=</span> <span class="n">inC</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">outC</span> <span class="o">=</span> <span class="n">outC</span>
        <span class="k">if</span> <span class="n">inC</span><span class="o">.</span><span class="n">filePath</span><span class="p">()</span> <span class="o">!=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_lastInputFilePath</span><span class="p">:</span>
          <span class="bp">self</span><span class="o">.</span><span class="n">selectFields</span><span class="p">(</span><span class="n">inC</span><span class="o">.</span><span class="n">filePath</span><span class="p">(),</span> <span class="n">inC</span><span class="o">.</span><span class="n">isLatLon</span><span class="p">(),</span> <span class="n">inC</span><span class="o">.</span><span class="n">ell2Ortho</span><span class="p">())</span>
          <span class="bp">self</span><span class="o">.</span><span class="n">_lastInputFilePath</span> <span class="o">=</span> <span class="n">inC</span><span class="o">.</span><span class="n">filePath</span><span class="p">()</span>
        <span class="k">else</span><span class="p">:</span>
          <span class="bp">self</span><span class="o">.</span><span class="n">_convertFile</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_lastSelection</span><span class="p">)</span>
      <span class="k">else</span><span class="p">:</span>
        <span class="k">pass</span>

<div class="viewcode-block" id="CoordDialog.selectFields"><a class="viewcode-back" href="../../ccqw.html#ccqw.coordDialog.CoordDialog.selectFields">[docs]</a>  <span class="k">def</span> <span class="nf">selectFields</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">pn</span><span class="p">,</span> <span class="n">longLat</span><span class="p">,</span> <span class="n">ortho</span><span class="o">=</span><span class="bp">None</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot; Select fields for file pn</span>

<span class="sd">    :param pn: pathname of the file from which select the fields</span>
<span class="sd">    :type pn: string, unicode</span>
<span class="sd">    :param longLat: True (geographic coordinates) or False (easting, northing)</span>
<span class="sd">                         requiredIndexes</span>
<span class="sd">    :type longLat: bool</span>
<span class="sd">    :param ortho: Orthometric height or None</span>
<span class="sd">    :type ortho: float or None</span>
<span class="sd">    :raises:</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">dlg</span> <span class="o">=</span> <span class="n">FieldsWizard</span><span class="p">(</span><span class="n">pathName</span><span class="o">=</span><span class="n">pn</span><span class="p">,</span> <span class="n">longLat</span><span class="o">=</span><span class="n">longLat</span><span class="p">,</span> <span class="n">ortho</span><span class="o">=</span><span class="n">ortho</span><span class="p">)</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">dlg</span><span class="o">.</span><span class="n">selectionDoneSignal</span><span class="o">.</span><span class="n">connect</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_convertFile</span><span class="p">)</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">dlg</span><span class="o">.</span><span class="n">exec_</span><span class="p">()</span>
</div>
  <span class="k">def</span> <span class="nf">_convertFile</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">d</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot; Format has been selected, close dialog and convert file</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">_lastSelection</span> <span class="o">=</span> <span class="n">d</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">dlg</span><span class="o">.</span><span class="n">close</span><span class="p">()</span>
    <span class="n">tic</span> <span class="o">=</span> <span class="n">time</span><span class="o">.</span><span class="n">time</span><span class="p">()</span>

    <span class="c"># Read ASCII file</span>
    <span class="n">names</span> <span class="o">=</span> <span class="n">d</span><span class="p">[</span><span class="s">&#39;names&#39;</span><span class="p">]</span>
    <span class="n">data</span> <span class="o">=</span> <span class="n">readASCII</span><span class="p">(</span><span class="n">d</span><span class="p">[</span><span class="s">&#39;pathName&#39;</span><span class="p">],</span> <span class="n">names</span><span class="p">,</span> <span class="n">d</span><span class="p">[</span><span class="s">&#39;formats&#39;</span><span class="p">],</span>
      <span class="n">headerlines</span><span class="o">=</span><span class="n">d</span><span class="p">[</span><span class="s">&#39;headerLines&#39;</span><span class="p">],</span> <span class="n">removeEmptyLines</span><span class="o">=</span><span class="bp">True</span><span class="p">,</span> <span class="n">commentChars</span><span class="o">=</span><span class="s">&#39;#&#39;</span><span class="p">)</span>

    <span class="k">try</span><span class="p">:</span>
      <span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">,</span> <span class="n">z</span><span class="p">,</span> <span class="n">isOrtho</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">dlg</span><span class="o">.</span><span class="n">data2Degrees</span><span class="p">(</span><span class="n">data</span><span class="p">,</span> <span class="n">names</span><span class="p">)</span>
    <span class="k">except</span> <span class="ne">IndexError</span><span class="p">:</span>
      <span class="c"># Issue an error message</span>
      <span class="n">mbox</span> <span class="o">=</span> <span class="n">QtGui</span><span class="o">.</span><span class="n">QMessageBox</span><span class="p">()</span>
      <span class="n">mbox</span><span class="o">.</span><span class="n">setWindowTitle</span><span class="p">(</span><span class="n">QCA</span><span class="o">.</span><span class="n">translate</span><span class="p">(</span><span class="s">&quot;Error message&quot;</span><span class="p">,</span>
        <span class="s">&#39;ERROR reading input file.....&#39;</span><span class="p">))</span>
      <span class="n">mbox</span><span class="o">.</span><span class="n">setIcon</span><span class="p">(</span><span class="n">QtGui</span><span class="o">.</span><span class="n">QMessageBox</span><span class="o">.</span><span class="n">Critical</span><span class="p">)</span>
      <span class="n">mbox</span><span class="o">.</span><span class="n">setInformativeText</span><span class="p">(</span><span class="n">QCA</span><span class="o">.</span><span class="n">translate</span><span class="p">(</span><span class="s">&quot;Error message&quot;</span><span class="p">,</span>
        <span class="s">&quot;ERROR!</span><span class="se">\n</span><span class="s">Cannot understand input file:</span><span class="se">\n</span><span class="s">&quot;</span>
        <span class="s">&quot;Maybe format or projection is wrong?&quot;</span><span class="p">))</span>
      <span class="n">mbox</span><span class="o">.</span><span class="n">setStandardButtons</span><span class="p">(</span><span class="n">QtGui</span><span class="o">.</span><span class="n">QMessageBox</span><span class="o">.</span><span class="n">Ok</span><span class="p">)</span>
      <span class="n">mbox</span><span class="o">.</span><span class="n">setDefaultButton</span><span class="p">(</span><span class="n">QtGui</span><span class="o">.</span><span class="n">QMessageBox</span><span class="o">.</span><span class="n">Ok</span><span class="p">)</span>
      <span class="n">mbox</span><span class="o">.</span><span class="n">button</span><span class="p">(</span><span class="n">QtGui</span><span class="o">.</span><span class="n">QMessageBox</span><span class="o">.</span><span class="n">Ok</span><span class="p">)</span><span class="o">.</span><span class="n">setText</span><span class="p">(</span><span class="n">QCA</span><span class="o">.</span><span class="n">translate</span><span class="p">(</span><span class="s">&quot;Error message&quot;</span><span class="p">,</span>
        <span class="s">&#39;Sorry&#39;</span><span class="p">))</span>
      <span class="n">ret</span> <span class="o">=</span> <span class="n">mbox</span><span class="o">.</span><span class="n">exec_</span><span class="p">()</span>
      <span class="k">return</span>

    <span class="n">x1</span><span class="p">,</span> <span class="n">y1</span><span class="p">,</span> <span class="n">z1</span><span class="p">,</span> <span class="n">ell2Ortho</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_transform</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">inC</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">outC</span><span class="p">,</span> <span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">,</span> <span class="n">z</span><span class="p">))</span>

    <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">outC</span><span class="o">.</span><span class="n">heightWidget</span><span class="o">.</span><span class="n">rep</span><span class="p">():</span>
      <span class="c"># Orthometric selected</span>
      <span class="n">z1</span> <span class="o">+=</span> <span class="n">ell2Ortho</span>
      <span class="n">hType</span> <span class="o">=</span> <span class="n">QCA</span><span class="o">.</span><span class="n">translate</span><span class="p">(</span><span class="s">&quot;HeightWidget&quot;</span><span class="p">,</span> <span class="s">&quot;Heights are orthometric&quot;</span><span class="p">)</span>
    <span class="k">else</span><span class="p">:</span>
      <span class="n">hType</span> <span class="o">=</span> <span class="n">QCA</span><span class="o">.</span><span class="n">translate</span><span class="p">(</span><span class="s">&quot;HeightWidget&quot;</span><span class="p">,</span> <span class="s">&quot;Heights are ellipsoidic&quot;</span><span class="p">)</span>

    <span class="n">xyzDegrees</span> <span class="o">=</span> <span class="p">(</span><span class="n">x1</span><span class="p">,</span> <span class="n">y1</span><span class="p">,</span> <span class="n">z1</span><span class="p">)</span>

    <span class="n">fmt</span> <span class="o">=</span> <span class="s">&#39;&#39;</span>
    <span class="n">xyz</span> <span class="o">=</span> <span class="p">[]</span>
    <span class="n">xdecimals</span><span class="p">,</span> <span class="n">ydecimals</span><span class="p">,</span> <span class="n">zdecimals</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">outC</span><span class="o">.</span><span class="n">decimals</span><span class="p">()</span>
    <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">decimals</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">((</span><span class="n">xdecimals</span><span class="p">,</span> <span class="n">ydecimals</span><span class="p">)):</span>
      <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">decimals</span><span class="p">,</span> <span class="nb">tuple</span><span class="p">):</span>
        <span class="k">if</span> <span class="n">i</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
          <span class="c"># Number of digits for longitude</span>
          <span class="n">degdigits</span> <span class="o">=</span> <span class="mi">3</span>
        <span class="k">else</span><span class="p">:</span>
          <span class="c"># Number of digits for latitude</span>
          <span class="n">degdigits</span> <span class="o">=</span> <span class="mi">2</span>

        <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">decimals</span><span class="p">)</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span>
          <span class="c"># Degrees</span>
          <span class="n">fmt</span> <span class="o">+=</span> <span class="s">&#39;</span><span class="si">%%</span><span class="s">.</span><span class="si">%d</span><span class="s">f&#39;</span> <span class="o">%</span> <span class="n">decimals</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
          <span class="n">xyz</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">xyzDegrees</span><span class="p">[</span><span class="n">i</span><span class="p">])</span>
        <span class="k">elif</span> <span class="nb">len</span><span class="p">(</span><span class="n">decimals</span><span class="p">)</span> <span class="o">==</span> <span class="mi">2</span><span class="p">:</span>
          <span class="c"># Degrees, Minutes.decimals</span>
          <span class="n">fmt</span> <span class="o">+=</span> <span class="s">&#39;</span><span class="si">%%</span><span class="s">0</span><span class="si">%d</span><span class="s">.0f</span><span class="si">%s%%</span><span class="s">0</span><span class="si">%d</span><span class="s">.</span><span class="si">%d</span><span class="s">f</span><span class="si">%s</span><span class="s">&#39;</span> <span class="o">%</span> <span class="p">(</span>
            <span class="n">degdigits</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_dmsChars</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="mi">3</span> <span class="o">+</span> <span class="n">xdecimals</span><span class="p">[</span><span class="mi">1</span><span class="p">],</span>
            <span class="n">xdecimals</span><span class="p">[</span><span class="mi">1</span><span class="p">],</span> <span class="bp">self</span><span class="o">.</span><span class="n">_dmsChars</span><span class="p">[</span><span class="mi">1</span><span class="p">])</span>
          <span class="n">dd</span><span class="p">,</span> <span class="n">mm</span> <span class="o">=</span> <span class="n">d2dm</span><span class="p">(</span><span class="n">xyzDegrees</span><span class="p">[</span><span class="n">i</span><span class="p">],</span> <span class="n">xdecimals</span><span class="p">[</span><span class="mi">1</span><span class="p">])</span>
          <span class="n">xyz</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">dd</span><span class="p">)</span>
          <span class="n">xyz</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">mm</span><span class="p">)</span>
        <span class="k">elif</span> <span class="nb">len</span><span class="p">(</span><span class="n">decimals</span><span class="p">)</span> <span class="o">==</span> <span class="mi">3</span><span class="p">:</span>
          <span class="c"># Degrees, Minutes, Seconds.decimals</span>
          <span class="n">fmt</span> <span class="o">+=</span> <span class="s">&#39;</span><span class="si">%%</span><span class="s">0</span><span class="si">%d</span><span class="s">.0f</span><span class="si">%s%%</span><span class="s">02.0f</span><span class="si">%s%%</span><span class="s">0</span><span class="si">%d</span><span class="s">.</span><span class="si">%d</span><span class="s">f</span><span class="si">%s</span><span class="s">&#39;</span> <span class="o">%</span> <span class="p">(</span>
            <span class="n">degdigits</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_dmsChars</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="bp">self</span><span class="o">.</span><span class="n">_dmsChars</span><span class="p">[</span><span class="mi">1</span><span class="p">],</span>
            <span class="mi">3</span> <span class="o">+</span> <span class="n">xdecimals</span><span class="p">[</span><span class="mi">2</span><span class="p">],</span> <span class="n">xdecimals</span><span class="p">[</span><span class="mi">2</span><span class="p">],</span> <span class="bp">self</span><span class="o">.</span><span class="n">_dmsChars</span><span class="p">[</span><span class="mi">2</span><span class="p">])</span>
          <span class="n">dd</span><span class="p">,</span> <span class="n">mm</span><span class="p">,</span> <span class="n">ss</span> <span class="o">=</span> <span class="n">d2dms</span><span class="p">(</span><span class="n">xyzDegrees</span><span class="p">[</span><span class="n">i</span><span class="p">],</span> <span class="n">xdecimals</span><span class="p">[</span><span class="mi">2</span><span class="p">])</span>
          <span class="n">xyz</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">dd</span><span class="p">)</span>
          <span class="n">xyz</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">mm</span><span class="p">)</span>
          <span class="n">xyz</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">ss</span><span class="p">)</span>
      <span class="k">else</span><span class="p">:</span>
        <span class="n">fmt</span> <span class="o">+=</span> <span class="s">&#39; </span><span class="si">%%</span><span class="s">.</span><span class="si">%d</span><span class="s">f&#39;</span> <span class="o">%</span> <span class="n">xdecimals</span>
        <span class="n">xyz</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">xyzDegrees</span><span class="p">[</span><span class="n">i</span><span class="p">])</span>
      <span class="n">fmt</span> <span class="o">+=</span> <span class="s">&#39; &#39;</span>

    <span class="n">fmt</span> <span class="o">+=</span> <span class="s">&#39; </span><span class="si">%%</span><span class="s">.</span><span class="si">%d</span><span class="s">f</span><span class="se">\n</span><span class="s">&#39;</span> <span class="o">%</span> <span class="n">zdecimals</span>
    <span class="n">xyz</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">xyzDegrees</span><span class="p">[</span><span class="mi">2</span><span class="p">])</span>

    <span class="n">xyz</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">vstack</span><span class="p">(</span><span class="n">xyz</span><span class="p">)</span>

    <span class="c"># Create a header</span>
    <span class="n">header</span> <span class="o">=</span> <span class="n">QCA</span><span class="o">.</span><span class="n">translate</span><span class="p">(</span><span class="s">&quot;outfile&quot;</span><span class="p">,</span> <span class="s">&quot;# Converted on </span><span class="si">%s</span><span class="s">:</span><span class="se">\n</span><span class="s">&quot;</span><span class="p">)</span> <span class="o">%</span> <span class="p">(</span><span class="n">time</span><span class="o">.</span><span class="n">asctime</span><span class="p">())</span>
    <span class="n">header</span> <span class="o">+=</span> <span class="n">QCA</span><span class="o">.</span><span class="n">translate</span><span class="p">(</span><span class="s">&quot;outfile&quot;</span><span class="p">,</span> <span class="s">&quot;# From Proj.4: &#39;</span><span class="si">%s</span><span class="s">&#39; - </span><span class="si">%s</span><span class="se">\n</span><span class="s">&quot;</span><span class="p">)</span> <span class="o">%</span> <span class="p">(</span>
      <span class="bp">self</span><span class="o">.</span><span class="n">inC</span><span class="o">.</span><span class="n">projString</span><span class="p">(),</span> <span class="n">hType</span><span class="p">)</span>
    <span class="n">header</span> <span class="o">+=</span> <span class="n">QCA</span><span class="o">.</span><span class="n">translate</span><span class="p">(</span><span class="s">&quot;outfile&quot;</span><span class="p">,</span> <span class="s">&quot;#   To Proj.4: &#39;</span><span class="si">%s</span><span class="s">&#39; - </span><span class="si">%s</span><span class="se">\n</span><span class="s">&quot;</span><span class="p">)</span> <span class="o">%</span> <span class="p">(</span>
      <span class="bp">self</span><span class="o">.</span><span class="n">outC</span><span class="o">.</span><span class="n">projString</span><span class="p">(),</span> <span class="n">hType</span><span class="p">)</span>

    <span class="c">#writeASCII(self.outC.filePath(), xyz, fmt, header)</span>
    <span class="n">tf</span> <span class="o">=</span> <span class="n">ThreadedFunc</span><span class="p">(</span><span class="n">writeASCII</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">outC</span><span class="o">.</span><span class="n">filePath</span><span class="p">(),</span> <span class="n">xyz</span><span class="p">,</span> <span class="n">fmt</span><span class="p">,</span> <span class="n">header</span><span class="p">)</span>
    <span class="n">pd</span> <span class="o">=</span> <span class="n">ProgressDialog</span><span class="p">(</span><span class="n">tf</span><span class="p">,</span> <span class="n">title</span><span class="o">=</span><span class="n">QCA</span><span class="o">.</span><span class="n">translate</span><span class="p">(</span><span class="s">&quot;ProgressDialog&quot;</span><span class="p">,</span>
      <span class="s">&quot;Conversion in progress...&quot;</span><span class="p">),</span>
      <span class="n">msg</span><span class="o">=</span><span class="n">QCA</span><span class="o">.</span><span class="n">translate</span><span class="p">(</span><span class="s">&quot;ProgressDialog&quot;</span><span class="p">,</span> <span class="s">&quot;Converting...&quot;</span><span class="p">))</span>

    <span class="c"># Issue a &quot;Done&quot; message</span>
    <span class="n">mbox</span> <span class="o">=</span> <span class="n">QtGui</span><span class="o">.</span><span class="n">QMessageBox</span><span class="p">()</span>
    <span class="n">mbox</span><span class="o">.</span><span class="n">setWindowTitle</span><span class="p">(</span><span class="n">QCA</span><span class="o">.</span><span class="n">translate</span><span class="p">(</span><span class="s">&quot;Done message&quot;</span><span class="p">,</span> <span class="s">&#39;File Conversion&#39;</span><span class="p">))</span>
    <span class="n">mbox</span><span class="o">.</span><span class="n">setIcon</span><span class="p">(</span><span class="n">QtGui</span><span class="o">.</span><span class="n">QMessageBox</span><span class="o">.</span><span class="n">Information</span><span class="p">)</span>
    <span class="n">mbox</span><span class="o">.</span><span class="n">setInformativeText</span><span class="p">(</span><span class="n">QCA</span><span class="o">.</span><span class="n">translate</span><span class="p">(</span><span class="s">&quot;Done message&quot;</span><span class="p">,</span>
      <span class="s">&quot;File has been convertd to </span><span class="si">%s</span><span class="se">\n</span><span class="s">&quot;</span>
      <span class="s">&quot;Output format is &#39;</span><span class="si">%s</span><span class="s">&#39;.&quot;</span><span class="p">)</span> <span class="o">%</span>
      <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">outC</span><span class="o">.</span><span class="n">filePath</span><span class="p">(),</span> <span class="bp">self</span><span class="o">.</span><span class="n">outC</span><span class="o">.</span><span class="n">coordFormat</span><span class="p">()))</span>
    <span class="n">mbox</span><span class="o">.</span><span class="n">setStandardButtons</span><span class="p">(</span><span class="n">QtGui</span><span class="o">.</span><span class="n">QMessageBox</span><span class="o">.</span><span class="n">Ok</span><span class="p">)</span>
    <span class="n">mbox</span><span class="o">.</span><span class="n">setDefaultButton</span><span class="p">(</span><span class="n">QtGui</span><span class="o">.</span><span class="n">QMessageBox</span><span class="o">.</span><span class="n">Ok</span><span class="p">)</span>
    <span class="n">mbox</span><span class="o">.</span><span class="n">button</span><span class="p">(</span><span class="n">QtGui</span><span class="o">.</span><span class="n">QMessageBox</span><span class="o">.</span><span class="n">Ok</span><span class="p">)</span><span class="o">.</span><span class="n">setText</span><span class="p">(</span>
      <span class="n">QCA</span><span class="o">.</span><span class="n">translate</span><span class="p">(</span><span class="s">&quot;Done message&quot;</span><span class="p">,</span> <span class="s">&#39;Ok&#39;</span><span class="p">))</span>
    <span class="n">ret</span> <span class="o">=</span> <span class="n">mbox</span><span class="o">.</span><span class="n">exec_</span><span class="p">()</span>

<div class="viewcode-block" id="CoordDialog.fileMode"><a class="viewcode-back" href="../../ccqw.html#ccqw.coordDialog.CoordDialog.fileMode">[docs]</a>  <span class="k">def</span> <span class="nf">fileMode</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot; Return True if widget is in `File` mode</span>

<span class="sd">      :returns: widget file mode</span>
<span class="sd">      :rtype: bool</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_fileMode</span>
</div>
<div class="viewcode-block" id="CoordDialog.changed"><a class="viewcode-back" href="../../ccqw.html#ccqw.coordDialog.CoordDialog.changed">[docs]</a>  <span class="k">def</span> <span class="nf">changed</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">what</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot; Something changed: either coordinates or Datum / Projection.</span>

<span class="sd">        Transform coordinates of the &quot;other&quot; point accordingly</span>

<span class="sd">    :param what: argument of the changedSignal emitted by the coordWidget</span>
<span class="sd">    :type what: Python Object</span>
<span class="sd">    :raises:</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="n">changed</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sender</span><span class="p">()</span>
    <span class="n">cWidgets</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">cWidgets</span><span class="p">[:]</span>
    <span class="n">cWidgets</span><span class="o">.</span><span class="n">remove</span><span class="p">(</span><span class="n">changed</span><span class="p">)</span>
    <span class="n">unchanged</span> <span class="o">=</span> <span class="n">cWidgets</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>

    <span class="k">if</span> <span class="n">what</span> <span class="o">==</span> <span class="s">&#39;point&#39;</span><span class="p">:</span>
      <span class="n">x1</span><span class="p">,</span> <span class="n">y1</span><span class="p">,</span> <span class="n">z1</span><span class="p">,</span> <span class="n">ell2Ortho</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_transform</span><span class="p">(</span><span class="n">changed</span><span class="p">,</span> <span class="n">unchanged</span><span class="p">,</span> <span class="n">changed</span><span class="p">)</span>
      <span class="c"># Update widget&#39;s value</span>
      <span class="n">unchanged</span><span class="o">.</span><span class="n">setValue</span><span class="p">(</span><span class="n">x1</span><span class="p">,</span> <span class="n">y1</span><span class="p">,</span> <span class="n">z1</span><span class="p">)</span>
      <span class="c"># No need to change ell2Ortho if we don&#39;t change Datum</span>
    <span class="k">elif</span> <span class="n">what</span> <span class="o">==</span> <span class="s">&#39;proj&#39;</span><span class="p">:</span>
      <span class="n">x1</span><span class="p">,</span> <span class="n">y1</span><span class="p">,</span> <span class="n">z1</span><span class="p">,</span> <span class="n">ell2Ortho</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_transform</span><span class="p">(</span><span class="n">unchanged</span><span class="p">,</span> <span class="n">changed</span><span class="p">,</span> <span class="n">unchanged</span><span class="p">)</span>
      <span class="c"># Update widget&#39;s value</span>
      <span class="n">changed</span><span class="o">.</span><span class="n">setValue</span><span class="p">(</span><span class="n">x1</span><span class="p">,</span> <span class="n">y1</span><span class="p">,</span> <span class="n">z1</span><span class="p">)</span>
      <span class="n">changed</span><span class="o">.</span><span class="n">setEll2Ortho</span><span class="p">(</span><span class="n">ell2Ortho</span><span class="p">)</span>
      <span class="n">unchanged</span><span class="o">.</span><span class="n">setEll2Ortho</span><span class="p">(</span><span class="n">ell2Ortho</span><span class="p">)</span>
      <span class="c"># Clear lastInputFilePath to force input fields selection</span>
      <span class="bp">self</span><span class="o">.</span><span class="n">_lastInputFilePath</span> <span class="o">=</span> <span class="bp">None</span>
    <span class="k">elif</span> <span class="n">what</span> <span class="o">==</span> <span class="s">&#39;File On&#39;</span><span class="p">:</span>
      <span class="c"># Enable File Conversion Mode</span>
      <span class="k">if</span> <span class="n">changed</span><span class="o">.</span><span class="n">filePickerMode</span><span class="p">()</span> <span class="o">==</span> <span class="n">unchanged</span><span class="o">.</span><span class="n">filePickerMode</span><span class="p">():</span>
        <span class="c">#########################</span>
        <span class="c"># THIS HAPPENS ONLY ONCE!</span>
        <span class="c">#########################</span>
        <span class="c"># Both are input: Set to output the unchanged:</span>
        <span class="n">unchanged</span><span class="o">.</span><span class="n">setFilePickerMode</span><span class="p">(</span><span class="n">FilePicker</span><span class="o">.</span><span class="n">OutputMode</span><span class="p">)</span>
        <span class="c"># Disable &quot;File&quot; selection in unchanged</span>
        <span class="n">unchanged</span><span class="o">.</span><span class="n">enableFileMode</span><span class="p">(</span><span class="bp">False</span><span class="p">)</span>

      <span class="c"># Show both file pickers</span>
      <span class="n">changed</span><span class="o">.</span><span class="n">showFilePicker</span><span class="p">(</span><span class="bp">True</span><span class="p">)</span>
      <span class="n">unchanged</span><span class="o">.</span><span class="n">showFilePicker</span><span class="p">(</span><span class="bp">True</span><span class="p">)</span>
      <span class="bp">self</span><span class="o">.</span><span class="n">_fileMode</span> <span class="o">=</span> <span class="bp">True</span>
      <span class="bp">self</span><span class="o">.</span><span class="n">convertBtn</span><span class="o">.</span><span class="n">setHidden</span><span class="p">(</span><span class="bp">False</span><span class="p">)</span>
      <span class="bp">self</span><span class="o">.</span><span class="n">adjustSize</span><span class="p">()</span>
    <span class="k">elif</span> <span class="n">what</span> <span class="o">==</span> <span class="s">&#39;File Off&#39;</span><span class="p">:</span>
      <span class="k">if</span> <span class="n">changed</span><span class="o">.</span><span class="n">filePickerMode</span><span class="p">()</span> <span class="o">==</span> <span class="n">FilePicker</span><span class="o">.</span><span class="n">InputMode</span><span class="p">:</span>
        <span class="c"># Hide both file pickers</span>
        <span class="n">changed</span><span class="o">.</span><span class="n">showFilePicker</span><span class="p">(</span><span class="bp">False</span><span class="p">)</span>
        <span class="n">unchanged</span><span class="o">.</span><span class="n">showFilePicker</span><span class="p">(</span><span class="bp">False</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_fileMode</span> <span class="o">=</span> <span class="bp">False</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">convertBtn</span><span class="o">.</span><span class="n">setHidden</span><span class="p">(</span><span class="bp">True</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">adjustSize</span><span class="p">()</span>
</div>
  <span class="k">def</span> <span class="nf">_transform</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">p0</span><span class="p">,</span> <span class="n">p1</span><span class="p">,</span> <span class="n">p</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot; Transform coordinates of point(s) p from p0 to p1</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">p</span><span class="p">,</span> <span class="n">CoordWidget</span><span class="p">):</span>
      <span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">,</span> <span class="n">z</span> <span class="o">=</span> <span class="n">p</span><span class="o">.</span><span class="n">xyz</span><span class="p">()</span>
    <span class="k">else</span><span class="p">:</span>
      <span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">,</span> <span class="n">z</span> <span class="o">=</span> <span class="n">p</span>
    <span class="n">pointToConvert</span> <span class="o">=</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">,</span> <span class="n">z</span>
    <span class="n">fromProjection</span> <span class="o">=</span> <span class="n">p0</span><span class="o">.</span><span class="n">proj</span><span class="p">()</span>

    <span class="k">if</span> <span class="n">p0</span><span class="o">.</span><span class="n">datumShift</span><span class="p">()</span> <span class="ow">or</span> <span class="n">p1</span><span class="o">.</span><span class="n">datumShift</span><span class="p">()</span> <span class="ow">or</span> <span class="n">p0</span><span class="o">.</span><span class="n">geoidGrid</span><span class="p">()</span> <span class="ow">or</span> <span class="n">p1</span><span class="o">.</span><span class="n">geoidGrid</span><span class="p">():</span>
      <span class="c"># Transform p to p_WGS84</span>
      <span class="n">p84</span> <span class="o">=</span> <span class="n">Proj</span><span class="p">(</span><span class="n">CoordWidget</span><span class="o">.</span><span class="n">WGS84</span><span class="p">)</span>
      <span class="n">x84</span><span class="p">,</span> <span class="n">y84</span><span class="p">,</span> <span class="n">z84</span> <span class="o">=</span> <span class="n">transform</span><span class="p">(</span><span class="n">p0</span><span class="o">.</span><span class="n">proj</span><span class="p">(),</span> <span class="n">p84</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">,</span> <span class="n">z</span><span class="p">)</span>

    <span class="k">if</span> <span class="n">p1</span><span class="o">.</span><span class="n">datumShift</span><span class="p">()</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">p0</span><span class="o">.</span><span class="n">datumShift</span><span class="p">():</span>
      <span class="c"># ONLY p1</span>
      <span class="c"># Get correction for p_WGS84</span>
      <span class="n">lonc</span><span class="p">,</span> <span class="n">latc</span> <span class="o">=</span> <span class="n">p1</span><span class="o">.</span><span class="n">datumShift</span><span class="p">()</span><span class="o">.</span><span class="n">getLLCorrection</span><span class="p">((</span><span class="n">x84</span><span class="p">,</span> <span class="n">y84</span><span class="p">))</span>
      <span class="k">if</span> <span class="n">lonc</span> <span class="ow">is</span> <span class="bp">None</span><span class="p">:</span>
        <span class="n">noDatumShift</span><span class="p">((</span><span class="n">x84</span><span class="p">,</span> <span class="n">y84</span><span class="p">))</span>
        <span class="n">xyzT</span> <span class="o">=</span> <span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span>
      <span class="k">else</span><span class="p">:</span>
        <span class="k">if</span> <span class="n">p1</span><span class="o">.</span><span class="n">isLatLon</span><span class="p">():</span>
          <span class="n">unimplemented</span><span class="p">()</span>
          <span class="n">xyzT</span> <span class="o">=</span> <span class="n">transform</span><span class="p">(</span><span class="n">p84</span><span class="p">,</span> <span class="n">p1</span><span class="o">.</span><span class="n">proj</span><span class="p">(),</span> <span class="n">x</span> <span class="o">-</span> <span class="n">lonc</span><span class="p">,</span> <span class="n">y</span> <span class="o">-</span> <span class="n">latc</span><span class="p">)</span> <span class="o">+</span> <span class="p">(</span><span class="n">z</span><span class="p">,</span> <span class="p">)</span>
        <span class="k">else</span><span class="p">:</span>
          <span class="n">xyzT</span> <span class="o">=</span> <span class="n">p1</span><span class="o">.</span><span class="n">proj</span><span class="p">()(</span><span class="n">x84</span> <span class="o">+</span> <span class="n">lonc</span><span class="p">,</span> <span class="n">y84</span> <span class="o">+</span> <span class="n">latc</span><span class="p">)</span> <span class="o">+</span> <span class="p">(</span><span class="n">z</span><span class="p">,</span> <span class="p">)</span>
    <span class="k">elif</span> <span class="n">p0</span><span class="o">.</span><span class="n">datumShift</span><span class="p">()</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">p1</span><span class="o">.</span><span class="n">datumShift</span><span class="p">():</span>
      <span class="c"># ONLY p0</span>
      <span class="c"># Get correction for p_WGS84</span>
      <span class="n">lonc</span><span class="p">,</span> <span class="n">latc</span> <span class="o">=</span> <span class="n">p0</span><span class="o">.</span><span class="n">datumShift</span><span class="p">()</span><span class="o">.</span><span class="n">getLLCorrection</span><span class="p">((</span><span class="n">x84</span><span class="p">,</span> <span class="n">y84</span><span class="p">))</span>
      <span class="k">if</span> <span class="n">lonc</span> <span class="ow">is</span> <span class="bp">None</span><span class="p">:</span>
        <span class="n">noDatumShift</span><span class="p">((</span><span class="n">x84</span><span class="p">,</span> <span class="n">y84</span><span class="p">))</span>
        <span class="n">xyzT</span> <span class="o">=</span> <span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span>
      <span class="k">else</span><span class="p">:</span>
        <span class="k">if</span> <span class="n">p0</span><span class="o">.</span><span class="n">isLatLon</span><span class="p">():</span>
          <span class="n">unimplemented</span><span class="p">()</span>
          <span class="n">xyzT</span> <span class="o">=</span> <span class="n">transform</span><span class="p">(</span><span class="n">p84</span><span class="p">,</span> <span class="n">p1</span><span class="o">.</span><span class="n">proj</span><span class="p">(),</span> <span class="n">x</span> <span class="o">-</span> <span class="n">lonc</span><span class="p">,</span> <span class="n">y</span> <span class="o">-</span> <span class="n">latc</span><span class="p">)</span> <span class="o">+</span> <span class="p">(</span><span class="n">z</span><span class="p">,</span> <span class="p">)</span>
        <span class="k">else</span><span class="p">:</span>
          <span class="n">tx</span><span class="p">,</span> <span class="n">ty</span> <span class="o">=</span> <span class="n">p0</span><span class="o">.</span><span class="n">proj</span><span class="p">()(</span><span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">,</span> <span class="n">inverse</span><span class="o">=</span><span class="bp">True</span><span class="p">)</span>
          <span class="n">xyzT</span> <span class="o">=</span> <span class="n">transform</span><span class="p">(</span><span class="n">p84</span><span class="p">,</span> <span class="n">p1</span><span class="o">.</span><span class="n">proj</span><span class="p">(),</span> <span class="n">tx</span> <span class="o">-</span> <span class="n">lonc</span><span class="p">,</span> <span class="n">ty</span> <span class="o">-</span> <span class="n">latc</span><span class="p">)</span> <span class="o">+</span> <span class="p">(</span><span class="n">z</span><span class="p">,</span> <span class="p">)</span>
    <span class="k">elif</span> <span class="n">p0</span><span class="o">.</span><span class="n">datumShift</span><span class="p">()</span> <span class="ow">and</span> <span class="n">p1</span><span class="o">.</span><span class="n">datumShift</span><span class="p">():</span>
      <span class="c"># BOTH!</span>
      <span class="c"># Get correction for p_WGS84</span>
      <span class="n">lon0c</span><span class="p">,</span> <span class="n">lat0c</span> <span class="o">=</span> <span class="n">p0</span><span class="o">.</span><span class="n">datumShift</span><span class="p">()</span><span class="o">.</span><span class="n">getLLCorrection</span><span class="p">((</span><span class="n">x84</span><span class="p">,</span> <span class="n">y84</span><span class="p">))</span>
      <span class="n">lon1c</span><span class="p">,</span> <span class="n">lat1c</span> <span class="o">=</span> <span class="n">p1</span><span class="o">.</span><span class="n">datumShift</span><span class="p">()</span><span class="o">.</span><span class="n">getLLCorrection</span><span class="p">((</span><span class="n">x84</span><span class="p">,</span> <span class="n">y84</span><span class="p">))</span>
      <span class="k">if</span> <span class="n">lon0c</span> <span class="ow">is</span> <span class="bp">None</span> <span class="ow">or</span> <span class="n">lon1c</span> <span class="ow">is</span> <span class="bp">None</span><span class="p">:</span>
        <span class="n">noDatumShift</span><span class="p">((</span><span class="n">x84</span><span class="p">,</span> <span class="n">y84</span><span class="p">))</span>
        <span class="n">xyzT</span> <span class="o">=</span> <span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span>
      <span class="k">else</span><span class="p">:</span>
        <span class="k">if</span> <span class="n">p0</span><span class="o">.</span><span class="n">isLatLon</span><span class="p">():</span>
          <span class="n">unimplemented</span><span class="p">()</span>
          <span class="n">xyzT</span> <span class="o">=</span> <span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span>
        <span class="k">else</span><span class="p">:</span>
          <span class="n">tx</span><span class="p">,</span> <span class="n">ty</span> <span class="o">=</span> <span class="n">p0</span><span class="o">.</span><span class="n">proj</span><span class="p">()(</span><span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">,</span> <span class="n">inverse</span><span class="o">=</span><span class="bp">True</span><span class="p">)</span>
          <span class="n">xyzT</span> <span class="o">=</span> <span class="n">p1</span><span class="o">.</span><span class="n">proj</span><span class="p">()(</span><span class="n">tx</span> <span class="o">-</span> <span class="n">lon0c</span> <span class="o">+</span> <span class="n">lon1c</span><span class="p">,</span> <span class="n">ty</span> <span class="o">-</span> <span class="n">lat0c</span> <span class="o">+</span> <span class="n">lat1c</span><span class="p">)</span> <span class="o">+</span> <span class="p">(</span><span class="n">z</span><span class="p">,</span> <span class="p">)</span>
    <span class="k">else</span><span class="p">:</span>
      <span class="c"># No datumShift</span>
      <span class="n">xyzT</span> <span class="o">=</span> <span class="n">transform</span><span class="p">(</span><span class="n">p0</span><span class="o">.</span><span class="n">proj</span><span class="p">(),</span> <span class="n">p1</span><span class="o">.</span><span class="n">proj</span><span class="p">(),</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">,</span> <span class="n">z</span><span class="p">)</span>

    <span class="c"># Geoid Correction</span>
    <span class="n">ell2Ortho</span> <span class="o">=</span> <span class="bp">None</span>
    <span class="k">if</span> <span class="n">p0</span><span class="o">.</span><span class="n">geoidGrid</span><span class="p">():</span>
      <span class="c"># Get Geoid Correction</span>
      <span class="n">correction</span> <span class="o">=</span> <span class="n">p0</span><span class="o">.</span><span class="n">geoidGrid</span><span class="p">()</span><span class="o">.</span><span class="n">getCorrection</span><span class="p">((</span><span class="n">x84</span><span class="p">,</span> <span class="n">y84</span><span class="p">))</span>
      <span class="k">if</span> <span class="n">correction</span> <span class="ow">is</span> <span class="ow">not</span> <span class="bp">None</span><span class="p">:</span>
        <span class="n">ell2Ortho</span> <span class="o">=</span> <span class="o">-</span> <span class="n">correction</span>

    <span class="k">if</span> <span class="n">p1</span><span class="o">.</span><span class="n">geoidGrid</span><span class="p">():</span>
      <span class="c"># Get Geoid Correction</span>
      <span class="n">correction</span> <span class="o">=</span> <span class="n">p1</span><span class="o">.</span><span class="n">geoidGrid</span><span class="p">()</span><span class="o">.</span><span class="n">getCorrection</span><span class="p">((</span><span class="n">x84</span><span class="p">,</span> <span class="n">y84</span><span class="p">))</span>
      <span class="k">if</span> <span class="n">correction</span> <span class="ow">is</span> <span class="ow">not</span> <span class="bp">None</span><span class="p">:</span>
        <span class="k">if</span> <span class="n">ell2Ortho</span> <span class="ow">is</span> <span class="bp">None</span><span class="p">:</span>
          <span class="n">ell2Ortho</span> <span class="o">=</span> <span class="n">correction</span>
        <span class="k">else</span><span class="p">:</span>
          <span class="n">ell2Ortho</span> <span class="o">+=</span> <span class="n">correction</span>

    <span class="k">return</span> <span class="n">xyzT</span> <span class="o">+</span> <span class="p">(</span><span class="n">ell2Ortho</span><span class="p">,</span> <span class="p">)</span>
</div>
<span class="k">if</span> <span class="n">__name__</span> <span class="o">==</span> <span class="s">&#39;__main__&#39;</span><span class="p">:</span>
  <span class="kn">import</span> <span class="nn">os</span>
  <span class="kn">import</span> <span class="nn">argparse</span>
  <span class="kn">from</span> <span class="nn">signal</span> <span class="kn">import</span> <span class="n">signal</span><span class="p">,</span> <span class="n">SIGINT</span><span class="p">,</span> <span class="n">SIG_DFL</span>

  <span class="n">signal</span><span class="p">(</span><span class="n">SIGINT</span><span class="p">,</span> <span class="n">SIG_DFL</span><span class="p">)</span>
  <span class="n">app</span> <span class="o">=</span> <span class="n">QtGui</span><span class="o">.</span><span class="n">QApplication</span><span class="p">(</span><span class="n">sys</span><span class="o">.</span><span class="n">argv</span><span class="p">)</span>

  <span class="c"># i18n for standard widgets</span>
  <span class="n">qTranslator</span> <span class="o">=</span> <span class="n">QtCore</span><span class="o">.</span><span class="n">QTranslator</span><span class="p">()</span>
  <span class="n">ok</span> <span class="o">=</span> <span class="n">qTranslator</span><span class="o">.</span><span class="n">load</span><span class="p">(</span><span class="s">&quot;qt_&quot;</span> <span class="o">+</span> <span class="n">QtCore</span><span class="o">.</span><span class="n">QLocale</span><span class="o">.</span><span class="n">system</span><span class="p">()</span><span class="o">.</span><span class="n">name</span><span class="p">(),</span>
    <span class="n">QtCore</span><span class="o">.</span><span class="n">QLibraryInfo</span><span class="o">.</span><span class="n">location</span><span class="p">(</span><span class="n">QtCore</span><span class="o">.</span><span class="n">QLibraryInfo</span><span class="o">.</span><span class="n">TranslationsPath</span><span class="p">))</span>
  <span class="k">if</span> <span class="ow">not</span> <span class="n">ok</span><span class="p">:</span>
    <span class="c"># Workaround for italian</span>
    <span class="n">ok</span> <span class="o">=</span> <span class="n">qTranslator</span><span class="o">.</span><span class="n">load</span><span class="p">(</span><span class="s">&quot;qt_&quot;</span> <span class="o">+</span> <span class="n">QtCore</span><span class="o">.</span><span class="n">QLocale</span><span class="o">.</span><span class="n">system</span><span class="p">()</span><span class="o">.</span><span class="n">name</span><span class="p">())</span>
  <span class="n">app</span><span class="o">.</span><span class="n">installTranslator</span><span class="p">(</span><span class="n">qTranslator</span><span class="p">)</span>

  <span class="c"># i18n for our application</span>
  <span class="n">translator</span> <span class="o">=</span> <span class="n">QtCore</span><span class="o">.</span><span class="n">QTranslator</span><span class="p">()</span>
  <span class="n">ok</span> <span class="o">=</span> <span class="n">translator</span><span class="o">.</span><span class="n">load</span><span class="p">(</span><span class="s">&quot;i18n_&quot;</span> <span class="o">+</span>  <span class="n">QtCore</span><span class="o">.</span><span class="n">QLocale</span><span class="o">.</span><span class="n">system</span><span class="p">()</span><span class="o">.</span><span class="n">name</span><span class="p">())</span>
  <span class="n">app</span><span class="o">.</span><span class="n">installTranslator</span><span class="p">(</span><span class="n">translator</span><span class="p">)</span>

  <span class="c">#moloSartorioWGS84 = (((13., 45., 34.397), (45., 38., 49.879), 52.8),</span>
  <span class="n">moloSartorioWGS84</span> <span class="o">=</span> <span class="p">(((</span><span class="mf">13.763647000</span><span class="p">),</span> <span class="p">(</span><span class="mf">45.710551000</span><span class="p">),</span> <span class="mf">285.800</span><span class="p">),</span>
    <span class="s">&#39;+proj=latlong +datum=WGS84&#39;</span><span class="p">,</span>
    <span class="s">&#39;+init=epsg:3004 +towgs84=-122.74,-34.27,-22.83,&#39;</span>
    <span class="s">&#39;-1.884,-3.400,-3.030,-15.62&#39;</span><span class="p">,</span>
    <span class="bp">None</span><span class="p">,</span> <span class="s">&#39;Molo Sartorio&#39;</span><span class="p">)</span>

  <span class="n">moloSartorioUTM33</span> <span class="o">=</span> <span class="p">(((</span><span class="mf">403768.542</span><span class="p">,),</span> <span class="p">(</span><span class="mf">5062631.809</span><span class="p">,),</span> <span class="mf">285.8</span><span class="p">),</span>
    <span class="s">&#39;+proj=utm +zone=33 +ellps=WGS84 +datum=WGS84 +no_defs&#39;</span><span class="p">,</span>
    <span class="s">&#39;+proj=longlat +ellps=intl +pm=rome +no_defs&#39;</span><span class="p">,</span>
    <span class="bp">None</span><span class="p">,</span> <span class="s">&#39;Molo Sartorio&#39;</span><span class="p">)</span>

  <span class="n">parser</span> <span class="o">=</span> <span class="n">argparse</span><span class="o">.</span><span class="n">ArgumentParser</span><span class="p">(</span><span class="n">prog</span><span class="o">=</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">basename</span><span class="p">(</span><span class="n">sys</span><span class="o">.</span><span class="n">argv</span><span class="p">[</span><span class="mi">0</span><span class="p">]))</span>
  <span class="n">parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s">&#39;-p&#39;</span><span class="p">,</span> <span class="s">&#39;--point&#39;</span><span class="p">,</span> <span class="n">default</span><span class="o">=</span><span class="s">&quot;(0, 0, 0)&quot;</span><span class="p">,</span>
    <span class="n">help</span><span class="o">=</span><span class="n">QCA</span><span class="o">.</span><span class="n">translate</span><span class="p">(</span><span class="s">&#39;main&#39;</span><span class="p">,</span> <span class="s">&#39;point coordinates &#39;</span>
    <span class="s">&quot;(default: &#39;</span><span class="si">%(default)s</span><span class="s">&#39;)&quot;</span><span class="p">))</span>
  <span class="n">parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s">&#39;-u&#39;</span><span class="p">,</span> <span class="s">&#39;--upperProj&#39;</span><span class="p">,</span> <span class="n">default</span><span class="o">=</span><span class="n">CoordWidget</span><span class="o">.</span><span class="n">WGS84</span><span class="p">,</span>
    <span class="n">help</span><span class="o">=</span><span class="n">QCA</span><span class="o">.</span><span class="n">translate</span><span class="p">(</span><span class="s">&#39;main&#39;</span><span class="p">,</span> <span class="s">&#39;upper Proj.4 string &#39;</span>
    <span class="s">&quot;(default: &#39;</span><span class="si">%(default)s</span><span class="s">&#39;)&quot;</span><span class="p">))</span>
  <span class="n">parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s">&#39;-l&#39;</span><span class="p">,</span> <span class="s">&#39;--lowerProj&#39;</span><span class="p">,</span> <span class="n">default</span><span class="o">=</span><span class="n">CoordWidget</span><span class="o">.</span><span class="n">WGS84</span><span class="p">,</span>
    <span class="n">help</span><span class="o">=</span><span class="n">QCA</span><span class="o">.</span><span class="n">translate</span><span class="p">(</span><span class="s">&#39;main&#39;</span><span class="p">,</span> <span class="s">&#39;lower Proj.4 string &#39;</span>
    <span class="s">&quot;(default: &#39;</span><span class="si">%(default)s</span><span class="s">&#39;)&quot;</span><span class="p">))</span>
  <span class="n">parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s">&#39;-e&#39;</span><span class="p">,</span> <span class="s">&#39;--ell2Ortho&#39;</span><span class="p">,</span> <span class="n">default</span><span class="o">=</span><span class="s">&#39;None&#39;</span><span class="p">,</span>
    <span class="n">help</span><span class="o">=</span><span class="n">QCA</span><span class="o">.</span><span class="n">translate</span><span class="p">(</span><span class="s">&#39;main&#39;</span><span class="p">,</span>
    <span class="s">&#39;optional height to add to get orthometric height &#39;</span>
    <span class="s">&quot;(default: &#39;</span><span class="si">%(default)s</span><span class="s">&#39;)&quot;</span><span class="p">))</span>
  <span class="n">parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s">&#39;-n&#39;</span><span class="p">,</span> <span class="s">&#39;--name&#39;</span><span class="p">,</span> <span class="n">default</span><span class="o">=</span><span class="s">&#39;&#39;</span><span class="p">,</span>
    <span class="n">help</span><span class="o">=</span><span class="n">QCA</span><span class="o">.</span><span class="n">translate</span><span class="p">(</span><span class="s">&#39;main&#39;</span><span class="p">,</span>
    <span class="s">&#39;optional name for the dialog &#39;</span>
    <span class="s">&quot;(default: &#39;</span><span class="si">%(default)s</span><span class="s">&#39;)&quot;</span><span class="p">))</span>
  <span class="n">parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s">&#39;-U&#39;</span><span class="p">,</span> <span class="s">&#39;--upperMode&#39;</span><span class="p">,</span> <span class="n">default</span><span class="o">=</span><span class="nb">str</span><span class="p">(</span><span class="n">CoordWidget</span><span class="o">.</span><span class="n">ModeD</span><span class="p">),</span>
    <span class="n">help</span><span class="o">=</span><span class="n">QCA</span><span class="o">.</span><span class="n">translate</span><span class="p">(</span><span class="s">&#39;main&#39;</span><span class="p">,</span>
    <span class="s">&#39;optional upper widget representation [0..2] &#39;</span>
    <span class="s">&quot;(default: &#39;</span><span class="si">%(default)s</span><span class="s">&#39;)&quot;</span><span class="p">))</span>
  <span class="n">parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s">&#39;-L&#39;</span><span class="p">,</span> <span class="s">&#39;--lowerMode&#39;</span><span class="p">,</span> <span class="n">default</span><span class="o">=</span><span class="nb">str</span><span class="p">(</span><span class="n">CoordWidget</span><span class="o">.</span><span class="n">ModeDMS</span><span class="p">),</span>
    <span class="n">help</span><span class="o">=</span><span class="n">QCA</span><span class="o">.</span><span class="n">translate</span><span class="p">(</span><span class="s">&#39;main&#39;</span><span class="p">,</span>
    <span class="s">&#39;optional lower widget representation [0..2] &#39;</span>
    <span class="s">&quot;(default: &#39;</span><span class="si">%(default)s</span><span class="s">&#39;)&quot;</span><span class="p">))</span>
  <span class="n">parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s">&#39;-d&#39;</span><span class="p">,</span> <span class="s">&#39;--dmsChars&#39;</span><span class="p">,</span> <span class="n">default</span><span class="o">=</span><span class="s">u&quot;&quot;&quot;[&quot;°&quot;, &quot;&#39;&quot;, &#39;&quot;&#39;]&quot;&quot;&quot;</span><span class="p">,</span>
    <span class="n">help</span><span class="o">=</span><span class="n">QCA</span><span class="o">.</span><span class="n">translate</span><span class="p">(</span><span class="s">&#39;main&#39;</span><span class="p">,</span> <span class="s">&#39;degrees, minutes, seconds characters &#39;</span>
    <span class="s">&quot;(default: &#39;</span><span class="si">%(default)s</span><span class="s">&#39;)&quot;</span><span class="p">))</span>
  <span class="n">o</span> <span class="o">=</span> <span class="n">parser</span><span class="o">.</span><span class="n">parse_args</span><span class="p">(</span><span class="n">sys</span><span class="o">.</span><span class="n">argv</span><span class="p">[</span><span class="mi">1</span><span class="p">:])</span>

  <span class="c">#dialog = CoordDialog(*moloSartorioUTM33)</span>
  <span class="c">#dialog = CoordDialog(*moloSartorioWGS84)</span>
  <span class="n">dialog</span> <span class="o">=</span> <span class="n">CoordDialog</span><span class="p">(</span><span class="nb">eval</span><span class="p">(</span><span class="n">o</span><span class="o">.</span><span class="n">point</span><span class="p">),</span> <span class="n">o</span><span class="o">.</span><span class="n">upperProj</span><span class="p">,</span> <span class="n">o</span><span class="o">.</span><span class="n">lowerProj</span><span class="p">,</span>
    <span class="nb">eval</span><span class="p">(</span><span class="n">o</span><span class="o">.</span><span class="n">ell2Ortho</span><span class="p">),</span> <span class="n">o</span><span class="o">.</span><span class="n">name</span><span class="p">,</span> <span class="nb">eval</span><span class="p">(</span><span class="n">o</span><span class="o">.</span><span class="n">upperMode</span><span class="p">),</span> <span class="nb">eval</span><span class="p">(</span><span class="n">o</span><span class="o">.</span><span class="n">lowerMode</span><span class="p">),</span>
    <span class="nb">eval</span><span class="p">(</span><span class="n">o</span><span class="o">.</span><span class="n">dmsChars</span><span class="p">))</span>
  <span class="n">dialog</span><span class="o">.</span><span class="n">show</span><span class="p">()</span>
  <span class="n">app</span><span class="o">.</span><span class="n">exec_</span><span class="p">()</span>
</pre></div>

          </div>
        </div>
      </div>
      <div class="sphinxsidebar">
        <div class="sphinxsidebarwrapper">
            <p class="logo"><a href="../../index.html">
              <img class="logo" src="../../_static/ogs.png" alt="Logo"/>
            </a></p>
<div id="searchbox" style="display: none">
  <h3>Quick search</h3>
    <form class="search" action="../../search.html" method="get">
      <input type="text" name="q" />
      <input type="submit" value="Go" />
      <input type="hidden" name="check_keywords" value="yes" />
      <input type="hidden" name="area" value="default" />
    </form>
    <p class="searchtip" style="font-size: 90%">
    Enter search terms or a module, class or function name.
    </p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../../genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="../../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li><a href="../../index.html">CCQW 0.1.1 documentation</a> &raquo;</li>
          <li><a href="../index.html" >Module code</a> &raquo;</li> 
      </ul>
    </div>
    <div class="footer">
        &copy; Copyright 2012, Roberto Vidmar, Nicola Creati.
      Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1.3.
    </div>
  </body>
</html>